home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 0574.ZIP / VAMPIRE.C < prev    next >
Text File  |  1986-05-03  |  2KB  |  75 lines

  1. #include <stdio.h>
  2. #include <errno.h>
  3. char *logo = "\
  4. /*************************************************************************\n\
  5. **                                    **\n\
  6. **    vampire - sucks the BIOS rom contents out of the PC on which    **\n\
  7. **          it is executed. The rom contents are placed into    **\n\
  8. **          binary files named 'BIOS.ROM' and OTHER.ROM        **\n\
  9. **          The contents of those files can then be HEX'd with    **\n\
  10. **          ZAPLOAD by T. Jennings, HEX86 by Manx, or        **\n\
  11. **          BIN2HEX by Robert Pasky                **\n\
  12. **                                    **\n\
  13. **    ARGUMENTS: none                            **\n\
  14. **                                    **\n\
  15. **    AUTHOR:                                **\n\
  16. **    Edward I. Comer    1986                        **\n\
  17. **    404+296-1403                            **\n\
  18. **                                    **\n\
  19. **************************************************************************\n\
  20. */\n";
  21. #define    SEGMENT    0xf000
  22.  
  23. main(argc,argv)
  24. int argc;
  25. char *argv[];
  26. {
  27.     static char Sccsid[] = "@(#)vampire.c 1.2 - Edward Comer, 1986";
  28.     unsigned char file[16];
  29.  
  30.     if(argc > 1)
  31.     {
  32.         printf("%s",logo);
  33.         exit(0);
  34.     }
  35.     /*
  36.     ** initialize
  37.     */
  38.     printf("ROM contents are being copied to files BIOS.ROM,OTHER.ROM\n");
  39.  
  40.     /*
  41.     ** extract bios rom contents starting at 'offset'
  42.     */
  43.     strcpy(file,"BIOS.ROM");
  44.     rom2file(file,0x2000,0xe000);    /* where IBM-PC BIOS resides */
  45.     strcpy(file,"OTHER.ROM");
  46.     rom2file(file,0x8000,0x6000);    /* where basic is (if present) */
  47. }
  48. /*
  49. ** create a file containing the contents of the specified memory
  50. */
  51. rom2file(fname,siz,off)
  52. unsigned char *fname;
  53. unsigned int off,siz;
  54. {
  55.     register unsigned int size, offset;
  56.     FILE *ofd;
  57.  
  58.     if((ofd = fopen(fname,"w")) == NULL)
  59.     {
  60.         printf("cannot create output file %s\n,fname");
  61.         exit(errno);
  62.     }
  63.  
  64.     size = siz;
  65.     offset = off;
  66.  
  67.     printf("FILE <%s> contains %u bytes from %04x:%04x to %04x:%04x\n",
  68.         fname,size,SEGMENT,offset,SEGMENT,offset+(size-1));
  69.     for(;size;size--)
  70.     {
  71.         putc(peekb(offset++,SEGMENT),ofd);
  72.     }
  73.     fclose(ofd);
  74. }
  75.